<?php
class OperationClass {
	public $_explicitType = "presstrack.OperationClass";
    
	public $iOperationId;
	public $mLabel;
  	public $iSection;	
  	public $iIsChecked;
	public $arFactors;

	function __construct($idoperation) 
	{
		$this->iOperationId		= $idoperation;
		$this->iIsChecked		= false;
		$this->arFactors		= array();
			
		$this->ReadFromDb();
	}
	
	function ReadFromDb()
	{
		$sql = "SELECT label AS mLabel, section AS iSection "
			 . "FROM press_track_new.operation WHERE idoperation = $this->iOperationId LIMIT 1";
		$query_operation = mysql_query($sql);
				
		while ($row = mysql_fetch_object($query_operation)) 
		{ 
			$this->mLabel	= $row->mLabel;
			$this->iSection	= $row->iSection;
			
			$sql = "SELECT * FROM press_track_new.factor "
				 . "WHERE press_track_new.factor.operation = $this->iOperationId";
			$query_factor	= mysql_query($sql);
			while ($factor = mysql_fetch_object($query_factor)) 
			{
				$factor->ar_value = explode(",", $factor->value);
				$len = count($factor->ar_value);
				for ($i=0; $i < $len; $i++)
				{
					$factor->ar_value[$i] = trim($factor->ar_value[$i]);
				}
				$this->arFactors[] = clone $factor;
			}
		}	
	}		
}
?>